//
//  Person.m
//  02-ClassAndObject
//
//  Created by dllo on 16/7/5.
//  Copyright © 2016年 高雅馨. All rights reserved.
//

#import "Person.h"

@implementation Person
// 实现: 方法 加{}
- (void)sleep:(NSInteger)time{
    NSLog(@"C语言函数类型%ld", time);
}
- (void)setNmae:(NSString *)name {
    if (_name != name) {
        [name release];
        _name = [name retain];
    }
}
- (NSString *)name {
    return [[_name retain]autorelease];
}
/**
 *  指派初始化方法:无论调用哪个初始化方法都会执行这个初始化方法。
 */
- (instancetype)initWithName:(NSString *)name age:(NSInteger)age {
    self = [super init];
    if (self) {
        _name = name;
        _age = age;
    }
    return self;
}
+ (instancetype)personWithName:(NSString *)name age:(NSInteger)age {
    return [[[Person alloc] initWithName:name age:age] autorelease];
}
@end
